package com.heima.wemedia.listen;

import com.heima.common.constants.wemedia.NewsAutoScanConstants;
import com.heima.wemedia.service.WmNewsAutoScanService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Rabbit自动审核监听类
 */
@Component
@Slf4j
public class WemediaNewsAutoListener {
    @Autowired
    WmNewsAutoScanService wmNewsAutoScanService;

    // 接收审核队列消息 执行自动审核方法
    @RabbitListener(queuesToDeclare = {@Queue(name = NewsAutoScanConstants.WM_NEWS_AUTO_SCAN_QUEUE)})
    public void newsAutoScan(String newsId) {
        log.info("接收到 自动审核消息->:{}", newsId);
        boolean scanResult = wmNewsAutoScanService.autoScanWmNews(Integer.valueOf(newsId));
        log.info("接收到 自动审核结果->:{}", scanResult);
    }

}